package com.ryskoo.catering.productcate.domain;

import com.ryskoo.catering.productmain.domain.ProductMainPO;
import com.ryskoo.framework.core.bean.BasicPO;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import javax.persistence.*;
import java.util.List;

@Entity
@Table(name = "cater_product_category")
@Document(indexName = "product", type = "category")
public class ProductCategoryPO extends BasicPO {

    /*** 主键 */
    @org.springframework.data.annotation.Id
    @Id
    @Column(name = "uuid", columnDefinition = "char(32)", length = 32, nullable = false)
    private String uuid;

    /**
     * 分类名称
     */
    @Field(type = FieldType.String, analyzer = "ik_max_word", searchAnalyzer = "ik_smart", store = true)
    @Column(name = "name", columnDefinition = "varchar", length = 20)
    private String name;

    /**
     * 分类图片
     */
    @Column(name = "image", columnDefinition = "varchar", length = 100)
    private String image;

    /**
     * 状态 1-启用；0-不启用
     */
    @Column(name = "state")
    private boolean state = true;

    /**
     * 所属商户uuid
     */
    @Column(name = "vendor_uuid", columnDefinition = "char", length = 32)
    private String vendorUuid;

    /**
     * 所属商户名称
     */
    @Field(type = FieldType.String, analyzer = "ik_max_word", searchAnalyzer = "ik_smart", store = true)
    @Column(name = "vendor_name", columnDefinition = "varchar", length = 30)
    private String vendorName;

    /**
     * 排序
     */
    @Column(name = "position", columnDefinition = "int")
    private int position;

    /**
     * 商品分类的类型  1-普通分类；2-推荐分类（主要用于前台展示推荐和热门）
     */
    @Column(name = "type", columnDefinition = "int")
    private int type;

    /***
     * 商品集合
     */
    @Transient
    private List<ProductMainPO> productList;

    @Override
    public String getUuid() {
        return uuid;
    }

    @Override
    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public boolean isState() {
        return state;
    }

    public void setState(boolean state) {
        this.state = state;
    }

    public String getVendorUuid() {
        return vendorUuid;
    }

    public void setVendorUuid(String vendorUuid) {
        this.vendorUuid = vendorUuid;
    }

    public String getVendorName() {
        return vendorName;
    }

    public void setVendorName(String vendorName) {
        this.vendorName = vendorName;
    }

    public int getPosition() {
        return position;
    }

    public void setPosition(int position) {
        this.position = position;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public List<ProductMainPO> getProductList() {
        return productList;
    }

    public void setProductList(List<ProductMainPO> productList) {
        this.productList = productList;
    }
}
